home *** CD-ROM | disk | FTP | other *** search
Wrap
import javax.microedition.lcdui.Alert; import javax.microedition.lcdui.AlertType; import javax.microedition.lcdui.Command; import javax.microedition.lcdui.CommandListener; import javax.microedition.lcdui.Display; import javax.microedition.lcdui.Displayable; import javax.microedition.lcdui.Form; import javax.microedition.lcdui.Image; import javax.microedition.lcdui.ImageItem; import javax.microedition.midlet.MIDlet; import javax.microedition.midlet.MIDletStateChangeException; import javax.microedition.rms.RecordStore; public class ChessMIDlet extends MIDlet implements CommandListener, ChessDisplayable { private ChessCanvas chesscanvas = new ChessCanvas(); private Form form = new Form("A NotTheFly product"); private Form helpform; private Command helpCommand = new Command("Help", 2, 1); private Command playCommand = new Command("Play", 4, 1); private Command backCommand = new Command("Back", 2, 1); public ChessMIDlet() { this.form.addCommand(this.playCommand); this.form.addCommand(this.helpCommand); try { this.form.append(new ImageItem((String)null, Image.createImage("/about.png"), 3, (String)null)); } catch (Exception var1) { this.form.append("Fly_Chess - a game by NotTheFly Component Solutions"); } this.helpform = new Form("Fly_Chess help"); this.helpform.addCommand(this.backCommand); this.helpform.append("Fly_Chess makes it possible to play a chess game against a player on the internet. These players may include other cellular phone players \n\nTo play a chess-match: \nFirst 'Logon' to an internet chess server \nChallenge a player by sending a 'Match' command \nCheck if your match is accepted by using the 'Poll' command \nPlay the game by selecting moves and send them using the 'MOVE' button \n\nFor futher instructions and supported internet chess servers, please refer to the Fly_Chess webpage at www.notthefly.com\n\n"); this.helpform.append("Fly_Chess is written by Anko van Kreij for NotTheFly Component Solutions"); } public void commandAction(Command var1, Displayable var2) { if (var1 == this.backCommand) { this.makeCurrent(CU.getDisplay()); } if (var1 == this.helpCommand) { CU.getDisplay().setCurrent(this.helpform); this.helpform.setCommandListener(this); } if (var1 == this.playCommand) { ChessLogic var3 = this.chesscanvas.getChessLogic(); CommandsForm var4 = var3.getCommandsForm(); var4.makeCurrent(CU.getDisplay()); } } public void destroyApp(boolean var1) { } public void exit() { ChessGame var1 = this.chesscanvas.getChessLogic().getChessGame(); if (var1 != null) { Alert var2 = new Alert("Please wait", "Logging off from the chess server", (Image)null, (AlertType)null); var2.setTimeout(-2); CU.getDisplay().setCurrent(var2); var1.doPost("logoff", false); while(var1.postActive()) { } } this.destroyApp(false); ((MIDlet)this).notifyDestroyed(); } private void initRecordStore() { RecordStore var1 = null; try { var1 = RecordStore.openRecordStore("Chess", false); } catch (Exception var7) { try { var1 = RecordStore.openRecordStore("Chess", true); String var2 = "http://212.120.72.223:5911/chess/RequestServlet"; String var3 = "chess.unix-ag.uni-kl.de"; var1.addRecord(var2.getBytes(), 0, var2.length()); var1.addRecord(var3.getBytes(), 0, var3.length()); String var4 = ""; var1.addRecord(var4.getBytes(), 0, var4.length()); var1.addRecord(var4.getBytes(), 0, var4.length()); } catch (Exception var6) { CU.shout("Could not create RS: " + ((Throwable)var6).getMessage()); } } try { var1.closeRecordStore(); } catch (Exception var5) { CU.shout("RS error: " + ((Throwable)var5).getMessage()); } } public void makeCurrent(Display var1) { var1.setCurrent(this.form); this.form.setCommandListener(this); } public void pauseApp() { } public void startApp() throws MIDletStateChangeException { this.initRecordStore(); CU.setDisplay(Display.getDisplay(this)); CU.setChessMIDlet(this); this.makeCurrent(CU.getDisplay()); } }